
import quopri


class eleparse:

    def __init__(self):
        pass

    @staticmethod
    def str2quopri(src):
        ret = quopri.encodestring(src.encode())  # ret is bytes
        return ret.decode()

    @staticmethod
    def quopri2str(src):
        ret = quopri.decodestring(src)  # ret is bytes
        return ret.decode()

    @staticmethod
    # 检验是否含有中文字符
    # ref:https://blog.csdn.net/August1226/article/details/80626396
    def isContainChinese(src):
        for ch in src:
            if ('\u4e00' <= ch <= '\u9fa5'):
                return True
        return False

    @staticmethod
    # 检验是否全是中文字符
    # ref:https://blog.csdn.net/August1226/article/details/80626396
    def isAllChinese(src):
        for ch in src:
            if not('\u4e00' <= ch <= '\u9fa5'):
                return False
        return True
